// pages/articleList/articleList.js
const articleList = require("../../models/articleList");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    value:{},
    lineNum:3,
    more:"展开↓"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
    var res = await articleList();
    console.log(res.data);
    this.setData({
      value:res.data
    })
  },
  async onShow(){
    var res = await articleList();
    console.log(res.data);
    this.setData({
      value:res.data
    })
  },

  // 展开和收起
  more(){
    if(this.data.lineNum==3){
      this.setData({
        lineNum:20,
        more:"收起↑"
      })
    }else{
      this.setData({
        lineNum:3,
        more:"展开↓"
      })
    }
  },
  // 转到详情页
  gotoDetail(event){
    console.log(event.currentTarget.dataset.id);
    wx.navigateTo({
      url: `../articleDetail/articleDetail?id=${event.currentTarget.dataset.id}`
    })
  },
})